import request from '@/config/axios'

// CMS文章分类 VO
export interface CategoryVO {
  id: number // 自增编号
  parentId: number // 上级分类
  categoryName: string // 分类名称
  sortNum: number // 显示顺序
  status: number // 状态
  thumbnail: string // 缩略图
  remark: string // 分类介绍
}

// CMS文章分类 API
export const CategoryApi = {
  // 查询部门（精简)列表
  getSimpleCategoryList: async () => {
    return await request.get({ url: '/cms/category/simple-list' })
  },
  // 查询CMS文章分类列表
  getCategoryList: async (params) => {
    return await request.get({ url: `/cms/category/list`, params })
  },

  // 查询CMS文章分类详情
  getCategory: async (id: number) => {
    return await request.get({ url: `/cms/category/get?id=` + id })
  },

  // 新增CMS文章分类
  createCategory: async (data: CategoryVO) => {
    return await request.post({ url: `/cms/category/create`, data })
  },

  // 修改CMS文章分类
  updateCategory: async (data: CategoryVO) => {
    return await request.put({ url: `/cms/category/update`, data })
  },

  // 删除CMS文章分类
  deleteCategory: async (id: number) => {
    return await request.delete({ url: `/cms/category/delete?id=` + id })
  },

  // 导出CMS文章分类 Excel
  exportCategory: async (params) => {
    return await request.download({ url: `/cms/category/export-excel`, params })
  }
}